package cards;

import java.util.Random;

import cards.Card.FaceValue;

public class HoyleDeck implements Deck {

	private Card[] deck = new Card[52];
	private int numLeft = deck.length;
	
	public HoyleDeck() {
		int i = 0;
		for (Card.Suit suit : Card.Suit.values()) {
			for (FaceValue faceValue : Card.FaceValue.values()) {
				deck[i++] = new Card(suit, faceValue);
			}
		}
		shuffle();
	}

	public int getNumCards() {
		return deck.length;
	}

	public void shuffle() {
		Random rGen = new Random();

		for (int i = deck.length - 1; i > 0; i--) {
			int randomNumber = rGen.nextInt(i--);
			Card invisHold = deck[i];
			deck[i] = deck[randomNumber];
			deck[randomNumber] = invisHold;

		}
	}
	
	public Card[] getDeck() {
		return deck;
	}
	
	public Card deal(int numPlayers) {
		if (numLeft > 0) {
			return deck[--numLeft];
		}
		return null;

	}


}
